<?php
/**
* 
*/
class HttpResponce extends BaseResponce
{
	
	protected $_headers;
	protected $_headersOnly = false;
	
	protected $_cookies;
	
	public function __construct()
	{
		parent::__construct();
	}
	
	public function addHeader(IResponceObject $header){
		if(!in_array($this->_headers,$header)){
			$this->_headers[] = $header;
		}
	}
	
	public function addCookie(IResponceObject $cookie){
		if(!in_array($this->_cookies,$cookie)){
			$this->_cookies[] = $cookie;
		}
	}
	
	protected function _sendHeaders(){
		foreach ($this->_headers as $header) {
			$header -> send();
		}
	}
	
	protected function _sendCookies(){
		foreach ($this->_cookies as $cookie) {
			$cookie -> send();
		}
	}
	
	public function sendContent(){
		$this->_sendHeaders();
		if($this->_headersOnly){
			return;
		}
		
		$this->_sentCookies();
		
		parent::sendContent();
	}
}

?>